package code.example.zookeeper.apply.config;

import com.google.common.base.Strings;
import org.springframework.core.io.Resource;
import org.springframework.util.StringUtils;

import java.io.InputStream;
import java.util.Properties;
import java.util.function.BiConsumer;

public class ConfigParse {

    public ConfigNode parse(Resource resource) throws Exception{
        Properties  properties = new Properties();
        properties.load(resource.getInputStream());
        ConfigNode configNode   = new ConfigNode();
        properties.forEach(new BiConsumer<Object, Object>() {
            @Override
            public void accept(Object key, Object value) {
                configNode.inject((String)key,(String)value);
            }
        });
        return configNode;
    }
}
